<template>
	<view class="evaluate-view" @click="goEvalDetail(evalData)">
		<view class="evaluate-title">
			<view>评论 ({{evalNum}})</view>
			<view>
				<image src="/static/images/right-arrow.svg" mode="aspectFit"></image>
			</view>
		</view>
		<!-- 如果有评论就显示 -->
		<block v-if="evalNum > 0" v-for="(item,index) in evalData" :key="index">
			<!-- 评论头像 昵称 -->
			<view class="evaluate-user">
				<view>
					<image :src="item.avatarUrl" mode="aspectFill"></image>
				</view>
				<view>{{item.nickName}}</view>
			</view>
			<!-- 评论内容 -->
			<view class="evaluate-content">
				<text>{{item.eva_text}}</text>
				<!-- 评论图片 -->
				<view class="eva-image">
					<view v-for="(item2,index2) in item.eva_image" :key="index2">
						<image :src="item2.image" mode="aspectFill"></image>
					</view>
				</view>
			</view>
		</block>
	</view>
</template>

<script setup>
	import { defineProps } from 'vue'
	import {FeedBack} from "../../../public/package-js/feedBack.js"
	defineProps({
		 evalNum: Number,
		 evalData: Array
	})

	// 跳转详情页
	function goEvalDetail(evalData) {
		// console.log("evalData",evalData);
		if (evalData.length > 0) {
			uni.navigateTo({
				url: '/pages/all-evaluation/all-evaluation?goods_id=' + evalData[0].goods_id
			})
		}else{
			new FeedBack('该商品暂时没有评价哦~','none').toast()
		}
	}
</script>

<style scoped>
	.evaluate-view {
		background-color: #FFFFFF;
		padding: 20rpx;
		margin-top: -15rpx;
	}

	.evaluate-title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-weight: bold;
	}

	.evaluate-title view:nth-child(2) {
		width: 35rpx;
		height: 35rpx;
	}

	.evaluate-title image {
		width: 35rpx;
		height: 35rpx;
	}

	/* 分类 */
	.evaluate-sort {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		padding-top: 20rpx;
	}

	.evaluate-sort view {
		background-color: #fbf6e9;
		color: #56504b;
		padding: 10rpx;
		font-size: 27rpx;
		margin: 0 20rpx 20rpx 0;
		border-radius: 10rpx;
	}

	/* 头像昵称 */
	.evaluate-user {
		display: flex;
		align-items: center;
		padding: 20rpx 0;
		color: #787878;
	}

	.evaluate-user view:nth-child(1) {
		width: 50rpx;
		height: 50rpx;
		margin-right: 10rpx;
	}

	.evaluate-user image {
		width: 50rpx;
		height: 50rpx;
		border-radius: 50%;
	}

	/* 评论内容 */
	.evaluate-content text {
		line-height: 1.8;
		color: #232323;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.eva-image {
		display: flex;
		flex-wrap: wrap;
	}

	.eva-image image {
		width: 100%;
		height: 200rpx;
		border-radius: 5rpx;
		display: block;
	}

	.eva-image view {
		width: calc(33.3% - 5rpx*2);
		margin: 5rpx;
	}
</style>
